Like this:
I'd add a variable "counter" that will be incremented for each new file. then append this counter to the filename (the "&" operator appends strings and converts numbers to strings)
tell application "Photos"
activate
set imageSel to (get selection) -- get a list of selected images
set counter to 1
set currentfilename to ""
if imageSel is {} then
error "Please select an image."
else
repeat with im in imageSel
set title to the name of im
if not (exists (title)) then
set currentfilename to the filename of im as text -- retrieve the filename of image "Im"
set newname to currentfilename & "." & counter
set counter to counter + 1 -- increment the counter
set the name of im to newname -- write the newname to the title field
end if
end repeat
end if
return currentfilename -- return the filename of the last image
end tell
The spellchecker is continually corrupting the code😟 I hope, I found all "corrections"